Public Class MUKPOContainerScheduleExcel
    Inherits System.Web.UI.Page

    Const TEMPLATE_FILE_PATH As String = "Excel\ContainerSchedule.xls"
    Private SSRDataSet As ShippingStatusReportDS

    ' Private ASPxGrid1 As DevExpress.Web.ASPxGrid.ASPxGrid

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        SSRDataSet = getData()

        ExportExcel2()

        'Dim muk As New Web.MUK

        'ASPxGrid1 = muk.ASPxGrid1
    End Sub

    Private Sub ExportExcel2()
        Dim sb As New System.Text.StringBuilder

        Response.Clear()
        Response.ContentType = "application/msexcel"
        Response.AddHeader("content-disposition", "attachment; filename=""ContainerSchedule" & "_" & Utilities.GetRandomFileName() & ".xls""")
        GenTable(sb)
        Response.Write(sb.ToString)
        Response.End()
    End Sub

    Private Sub GenTable(ByRef sb As System.Text.StringBuilder)

        ' Table tag
        sb.Append("<TABLE cellSpacing=1 cellPadding=3 width=""100%""  border=1>")

        Me.GenHeader(sb)
        Me.GenRows(sb)

        ' Table end tag
        sb.Append("</table>")

    End Sub

    Private Function PSFormatString(ByVal value As String) As String
        Try
            Return value
        Catch ex As Exception
            Return ""
        End Try
    End Function

    Private Function PSFormatDate(ByVal value As Date) As String
        Try
            If value = Date.MinValue Then
                Return ""
            End If

            Return String.Format("=T(""{0:dd/MMM/yyyy}"")", value)
        Catch ex As Exception
            Return ""
        End Try
    End Function

    Private Function PSFormatNumber(ByVal value As Int32, ByVal length As Int32) As String
        Try
            Return String.Format("=T(""{0:D" & length.ToString & "}"")", value)
        Catch ex As Exception
            Return ""
        End Try
    End Function

    Private Sub GenHeader(ByRef sb As System.Text.StringBuilder)
        sb.Append("<tr style='font-weight: bold;height:40px; text-align:center'>")
        GenDataHeader(sb)
        GenExtensionHeader(sb)
        sb.Append("</tr>")
    End Sub

    Private Sub GenDataHeader(ByRef sb As System.Text.StringBuilder)
        sb.Append("<td style='width:40px;'>Req</td>")
        sb.Append("<td>Sales Order</td>")
        sb.Append("<td style='width:80px;'>Order Date</td>")
        sb.Append("<td>Bulk</td>")
        sb.Append("<td>Size</td>")
        sb.Append("<td>Pack</td>")
        sb.Append("<td>Type</td>")
        sb.Append("<td>Supp</td>")
        sb.Append("<td>O/No</td>")
        sb.Append("<td>Prim</td>")
        sb.Append("<td>Con</td>")
        sb.Append("<td>Acc No</td>")
        sb.Append("<td>Customer</td>")
        sb.Append("<td>Cust PO No</td>")
        sb.Append("<td>Final Destination</td>")
        sb.Append("<td>Arrival Port</td>")
        sb.Append("<td>Description</td>")
        sb.Append("<td style='width:80px;'>Factory ETD</td>")
        sb.Append("<td style='width:80px;'>Shipped Date</td>")
        sb.Append("<td>Shipping Line</td>")
        sb.Append("<td>Vessel</td>")
        sb.Append("<td>Container No</td>")
        sb.Append("<td style='width:80px;'>ETA</td>")
        sb.Append("<td>Wk</td>")        
        sb.Append("<td>Doc Received</td>")
        sb.Append("<td>P Inv Value</td>")
        sb.Append("<td style='width:80px;'>Completed Date</td>")
    End Sub

    Private Sub GenExtensionHeader(ByRef sb As System.Text.StringBuilder)
        sb.Append("<td style='width:100px;'>Docs rcvd from Factory</td>")
        sb.Append("<td>Docs</td>")
        sb.Append("<td style='width:100px;'>Opera HHT Date Entered</td>")
        sb.Append("<td style='width:100px;'>Docs sent to K&N</td>")
        sb.Append("<td style='width:100px;'>Del confirmed with customer</td>")
        sb.Append("<td>Time</td>")
        sb.Append("<td style='width:100px;'>Del confirmed with shipper</td>")
        sb.Append("<td style='width:100px;'>Delivered / Tally sheet received</td>")
        sb.Append("<td style='width:100px;'>VAT Inv Folio</td>")
        sb.Append("<td style='width:100px;'>Freight Inv Folio</td>")
        sb.Append("<td style='width:100px;'>Other Inv to check</td>")
        sb.Append("<td>Completed</td>")
    End Sub

    Private Sub GenRows(ByRef sb As System.Text.StringBuilder)

        Dim row As ShippingStatusReportDS.ShippingStatusReportRow
        Dim sl As CShippingLine

        For Each row In SSRDataSet.ShippingStatusReport.Rows
            sb.Append("<tr>")

            sl = New CShippingLine(row)

            GenDataCells(sb, sl)

            GenExtensionCells(sb)

            sb.Append("</tr>")
        Next

    End Sub

    Private Sub GenDataCells(ByRef sb As System.Text.StringBuilder, ByVal row As CShippingLine)
        sb.Append("<td style='text-align:center'>" & PSFormatNumber(row.REQ, 4) & "</td>")
        sb.Append("<td>" & IIf(row.IsSalesOrderNull, "", row.SalesOrder).ToString() & "</td>")
        sb.Append("<td style='text-align:center'>" & PSFormatDate(row.OrderDate) & "</td>")
        sb.Append("<td>" & PSFormatString(row.BulkType) & "</td>")
        sb.Append("<td>" & PSFormatString(row.ContainerSize) & "</td>") 'sb.Append("<td>" & a & "</td>")
        sb.Append("<td>" & PSFormatString(row.LP) & "</td>")
        sb.Append("<td>" & PSFormatString(row.PONo_Type) & "</td>")
        sb.Append("<td style='text-align:center'>" & PSFormatNumber(row.PONo_Supplier, 3) & "</td>")
        sb.Append("<td style='text-align:center'>" & PSFormatNumber(row.PONo_Number, 3) & "</td>")
        sb.Append("<td>" & PSFormatString(row.IsPrimary) & "</td>")
        sb.Append("<td style='text-align:center'>" & IIf(row.PONo_ConsolidationIsNull, "", row.PONo_Consolidation).ToString & "</td>")
        sb.Append("<td>" & PSFormatString(row.AccNo) & "</td>")
        sb.Append("<td>" & PSFormatString(row.CustomerOrLocation) & "</td>")
        sb.Append("<td>" & PSFormatString(row.CustPONo) & "</td>")
        sb.Append("<td>" & PSFormatString(row.FinalDestination) & "</td>")
        sb.Append("<td>" & PSFormatString(row.ArrivalPort) & "</td>")
        sb.Append("<td>" & PSFormatString(row.Description) & "</td>")
        sb.Append("<td style='text-align:center'>" & PSFormatDate(row.FactoryETD) & "</td>")
        sb.Append("<td style='text-align:center'>" & PSFormatDate(row.ShippingDate) & "</td>")
        sb.Append("<td>" & PSFormatString(row.ShippingLine) & "</td>")
        sb.Append("<td>" & PSFormatString(row.Vessel) & "</td>")
        sb.Append("<td>" & PSFormatString(row.ContainerNo) & "</td>")
        sb.Append("<td style='text-align:center'>" & PSFormatDate(row.ETA) & "</td>")
        sb.Append("<td style='text-align:center'>" & getWeek(row.ETA) & "</td>")    
        sb.Append("<td style='text-align:center'>" & PSFormatString(IIf(row.DocReceived, "Yes", "").ToString) & "</td>")
        sb.Append("<td>" & IIf(row.IsInvValueNull, "", row.InvValue).ToString() & "</td>")
        sb.Append("<td style='text-align:center'>" & PSFormatDate(row.CompletedDate) & "</td>")
    End Sub

    Function getWeek(ByVal value As Date) As String
        Try
            Return PSFormatNumber(Utilities.GetWeek(value), 2)
        Catch ex As Exception
            Return ""
        End Try
    End Function

    Private Sub GenExtensionCells(ByRef sb As System.Text.StringBuilder)
        For i As Int32 = 1 To 12
            sb.Append("<td></td>")
        Next
    End Sub

    'Private Sub ExportExcel()
    '    ' Export to Excel
    '    Dim filename As String = Request.PhysicalApplicationPath + "Excel\" + "ContainerSchedule" + System.Guid.NewGuid.ToString + ".xls"
    '    Dim ap As New Excel.Application

    '    ap.DisplayAlerts = False
    '    ap.UserControl = False
    '    ap.Visible = False

    '    Dim wbs As Excel.Workbooks
    '    Dim wb As Excel.Workbook

    '    wbs = ap.Workbooks

    '    Try
    '        wb = wbs.Open(Request.PhysicalApplicationPath + Me.TEMPLATE_FILE_PATH)


    '        'Me.FillMainInfo(wb)
    '        'Me.InsertDetailInfo(wb)

    '        wb.SaveAs(filename)

    '    Catch ex As Exception
    '        wb.Close()
    '        System.Runtime.InteropServices.Marshal.ReleaseComObject(wbs)
    '        ap.Quit()

    '        System.Runtime.InteropServices.Marshal.ReleaseComObject(ap)

    '        ap = Nothing

    '        GC.Collect()

    '        Throw New ApplicationException("Could not export to Excel. Please contact your Admin for more detail.", ex)
    '    End Try

    '    wb.Close()
    '    System.Runtime.InteropServices.Marshal.ReleaseComObject(wbs)
    '    ap.Quit()
    '    System.Runtime.InteropServices.Marshal.ReleaseComObject(ap)
    '    ap = Nothing
    '    GC.Collect()

    '    ' Read file into buffer
    '    Dim fs As New System.IO.FileStream(filename, IO.FileMode.Open)
    '    Dim len As Integer = CInt(fs.Length)
    '    Dim buf(len - 1) As Byte
    '    fs.Read(buf, 0, len)
    '    fs.Close()

    '    ' Delete(file)
    '    Dim f As System.IO.File
    '    f.Delete(filename)

    '    ' Output to user
    '    Response.Clear()
    '    Response.AddHeader("content-disposition", "filename=""" & "IV" & GetRandomFileName() & ".xls""")
    '    Response.ContentType = "application/vnd.ms-excel"
    '    Response.BinaryWrite(buf)
    '    Response.End()

    'End Sub

    Private Function getData() As ShippingStatusReportDS
        Dim myIDs As String = Request.QueryString("ids")
        Dim mySQLAdapter As SqlClient.SqlDataAdapter
        Dim mySelectCmd As SqlClient.SqlCommand
        Dim myDataSet As ShippingStatusReportDS
        Dim strQuery As String

        If myIDs <> "" Then
            myIDs = myIDs.TrimEnd(New Char() {","c})
            myIDs = myIDs.Replace(",", "','")
            myIDs = "('" & myIDs & "')"

            strQuery = "SELECT ID, REQ, OrderDate, ContainerSize, LP, PONo_Office," & _
                 "PONo_Type, PONo_Supplier, PONo_Number, IsPrimary, PONo_Consolidation, AccNo, CustomerOrLocation, " & _
                 "FinalDestination, Description, FactoryETD, ShippingDate, ShippingLine, Vessel, ContainerNo, " & _
                 "ETA, Week, ArrivalPort, PI, Payment, DocReceived, CompletedDate, BulkType, ModifiedDate, " & _
                 "InvValue, SalesOrder, CustPONo, ContainerDeliveried, SInvoiced, " & _
                 "getDate() CurrentDate FROM SHIPPINGSTATUSREPORT WHERE [ID] IN " & myIDs

            Select Case RequestContext.POType
                Case 0
                    strQuery = strQuery + " ORDER BY REQ ASC, IsPrimary ASC "
                Case 1
                    strQuery = strQuery + " ORDER BY PONo_Type ASC, REQ ASC, IsPrimary, PONo_Supplier  "
                Case 2
                    strQuery = strQuery + " ORDER BY FactoryETD, REQ, IsPrimary ASC "
                Case 3
                    strQuery = strQuery + " ORDER BY CustomerOrLocation, CustPONo, FinalDestination, REQ, IsPrimary ASC "
                Case 4
                    strQuery = strQuery + " ORDER BY ETA, REQ, IsPrimary ASC "
                Case 5
                    strQuery = strQuery + " ORDER BY PONo_Supplier, PONo_Number "
                Case 6
                    strQuery = strQuery + " ORDER BY ContainerDeliveried, REQ, IsPrimary ASC  "
                Case 7
                    strQuery = strQuery + " ORDER BY CustomerOrLocation, [PI], REQ, IsPrimary ASC"
                Case 8
                    strQuery = strQuery + " ORDER BY  REQ, IsPrimary ASC"
                Case 9
                    strQuery = strQuery + " ORDER BY SalesOrder, REQ, IsPrimary ASC"
                Case 10
                    strQuery = strQuery + " ORDER BY [SInvoiced], REQ, IsPrimary ASC"
                Case 11
                    strQuery = strQuery + " ORDER BY [CustomerOrLocation], [SInvoiced], REQ, IsPrimary ASC"
            End Select

            mySelectCmd = New SqlClient.SqlCommand(strQuery)
            mySelectCmd.Connection = New SqlClient.SqlConnection(Config.ConnectionString)

            mySQLAdapter = New SqlClient.SqlDataAdapter(mySelectCmd)

            mySQLAdapter.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "ShippingStatusReport", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("ID", "ID"), New System.Data.Common.DataColumnMapping("REQ", "REQ"), New System.Data.Common.DataColumnMapping("OrderDate", "OrderDate"), New System.Data.Common.DataColumnMapping("ContainerSize", "ContainerSize"), New System.Data.Common.DataColumnMapping("LP", "LP"), New System.Data.Common.DataColumnMapping("PONo_Office", "PONo_Office"), New System.Data.Common.DataColumnMapping("PONo_Type", "PONo_Type"), New System.Data.Common.DataColumnMapping("PONo_Supplier", "PONo_Supplier"), New System.Data.Common.DataColumnMapping("PONo_Number", "PONo_Number"), New System.Data.Common.DataColumnMapping("IsPrimary", "IsPrimary"), New System.Data.Common.DataColumnMapping("PONo_Consolidation", "PONo_Consolidation"), New System.Data.Common.DataColumnMapping("CustomerOrLocation", "CustomerOrLocation"), New System.Data.Common.DataColumnMapping("Description", "Description"), New System.Data.Common.DataColumnMapping("FactoryETD", "FactoryETD"), New System.Data.Common.DataColumnMapping("ShippingDate", "ShippingDate"), New System.Data.Common.DataColumnMapping("ShippingLine", "ShippingLine"), New System.Data.Common.DataColumnMapping("Vessel", "Vessel"), New System.Data.Common.DataColumnMapping("ContainerNo", "ContainerNo"), New System.Data.Common.DataColumnMapping("ETA", "ETA"), New System.Data.Common.DataColumnMapping("Week", "Week"), New System.Data.Common.DataColumnMapping("ArrivalPort", "ArrivalPort"), New System.Data.Common.DataColumnMapping("PI", "PI"), New System.Data.Common.DataColumnMapping("Payment", "Payment"), New System.Data.Common.DataColumnMapping("DocReceived", "DocReceived"), New System.Data.Common.DataColumnMapping("CompletedDate", "CompletedDate"), New System.Data.Common.DataColumnMapping("BulkType", "BulkType"), New System.Data.Common.DataColumnMapping("ModifiedDate", "ModifiedDate")})})

            myDataSet = New ShippingStatusReportDS

            If mySQLAdapter.Fill(myDataSet) > 0 Then
                Return myDataSet
            Else
                Throw New Exception("Data is empty")
            End If
        End If

        Throw New Exception("Data is empty")
    End Function

    Protected Class CShippingLine

        Private m_Row As ShippingStatusReportDS.ShippingStatusReportRow

        Public Sub New(ByVal row As ShippingStatusReportDS.ShippingStatusReportRow)
            m_Row = row
        End Sub

#Region "   Data Properties"
        Protected ReadOnly Property DataRow() As ShippingStatusReportDS.ShippingStatusReportRow
            Get
                Return m_Row
            End Get
        End Property

        Public ReadOnly Property ID() As System.Int32
            Get
                Return Me.DataRow.ID
            End Get
        End Property

        Public Property REQ() As System.Int32
            Get
                Return Me.DataRow.REQ
            End Get
            Set(ByVal Value As System.Int32)
                Me.DataRow.REQ = Value
            End Set
        End Property

        Public Property OrderDate() As System.DateTime
            Get
                If Me.DataRow.IsOrderDateNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.OrderDate
                End If
            End Get
            Set(ByVal Value As System.DateTime)
                If Value = Nothing Then
                    Me.DataRow.SetOrderDateNull()
                Else
                    Me.DataRow.OrderDate = Value
                End If
            End Set
        End Property

        Public Property ContainerSize() As System.String
            Get
                If Me.DataRow.IsContainerSizeNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.ContainerSize
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetContainerSizeNull()
                Else
                    Me.DataRow.ContainerSize = Value
                End If
            End Set
        End Property

        Public Property LP() As System.String
            Get
                If Me.DataRow.IsLPNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.LP
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetLPNull()
                Else
                    Me.DataRow.LP = Value
                End If
            End Set
        End Property

        Public Property PONo_Office() As System.String
            Get
                If Me.DataRow.IsPONo_OfficeNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.PONo_Office
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetPONo_OfficeNull()
                Else
                    Me.DataRow.PONo_Office = Value
                End If
            End Set
        End Property

        Public Property PONo_Type() As System.String
            Get
                Return Me.DataRow.PONo_Type
            End Get
            Set(ByVal Value As System.String)
                Me.DataRow.PONo_Type = Value
            End Set
        End Property

        Public Property PONo_Supplier() As System.Int32
            Get
                Return Me.DataRow.PONo_Supplier
            End Get
            Set(ByVal Value As System.Int32)
                Me.DataRow.PONo_Supplier = Value
            End Set
        End Property

        Public Property PONo_Number() As System.Int32
            Get
                Return Me.DataRow.PONo_Number
            End Get
            Set(ByVal Value As System.Int32)
                Me.DataRow.PONo_Number = Value
            End Set
        End Property

        Public Property IsPrimary() As System.String
            Get
                If Me.DataRow.IsIsPrimaryNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.IsPrimary
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetIsPrimaryNull()
                Else
                    Me.DataRow.IsPrimary = Value
                End If
            End Set
        End Property

        Public ReadOnly Property PONo_ConsolidationIsNull() As Boolean
            Get
                Return Me.DataRow.IsPONo_ConsolidationNull
            End Get
        End Property

        Public Property PONo_Consolidation() As System.Int32
            Get
                If Me.DataRow.IsPONo_ConsolidationNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.PONo_Consolidation
                End If
            End Get
            Set(ByVal Value As System.Int32)
                If Value = Nothing Then
                    Me.DataRow.SetPONo_ConsolidationNull()
                Else
                    Me.DataRow.PONo_Consolidation = Value
                End If
            End Set
        End Property

        Public Property AccNo() As System.String
            Get
                If Me.DataRow.IsAccNoNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.AccNo
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetAccNoNull()
                Else
                    Me.DataRow.AccNo = Value
                End If
            End Set
        End Property

        Public Property CustomerOrLocation() As System.String
            Get
                If Me.DataRow.IsCustomerOrLocationNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.CustomerOrLocation
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetCustomerOrLocationNull()
                Else
                    Me.DataRow.CustomerOrLocation = Value
                End If
            End Set
        End Property

        Public Property FinalDestination() As System.String
            Get
                If Me.DataRow.IsFinalDestinationNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.FinalDestination
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetFinalDestinationNull()
                Else
                    Me.DataRow.FinalDestination = Value
                End If
            End Set
        End Property

        Public Property Description() As System.String
            Get
                If Me.DataRow.IsDescriptionNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.Description
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetDescriptionNull()
                Else
                    Me.DataRow.Description = Value
                End If
            End Set
        End Property

        Public Property FactoryETD() As System.DateTime
            Get
                If Me.DataRow.IsFactoryETDNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.FactoryETD
                End If
            End Get
            Set(ByVal Value As System.DateTime)
                If Value = Nothing Then
                    Me.DataRow.SetFactoryETDNull()
                Else
                    Me.DataRow.FactoryETD = Value
                End If
            End Set
        End Property

        Public Property ShippingDate() As System.DateTime
            Get
                If Me.DataRow.IsShippingDateNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.ShippingDate
                End If
            End Get
            Set(ByVal Value As System.DateTime)
                If Value = Nothing Then
                    Me.DataRow.SetShippingDateNull()
                Else
                    Me.DataRow.ShippingDate = Value
                End If
            End Set
        End Property

        Public Property ShippingLine() As System.String
            Get
                If Me.DataRow.IsShippingLineNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.ShippingLine
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetShippingLineNull()
                Else
                    Me.DataRow.ShippingLine = Value
                End If
            End Set
        End Property

        Public Property Vessel() As System.String
            Get
                If Me.DataRow.IsVesselNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.Vessel
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetVesselNull()
                Else
                    Me.DataRow.Vessel = Value
                End If
            End Set
        End Property

        Public Property ContainerNo() As System.String
            Get
                If Me.DataRow.IsContainerNoNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.ContainerNo
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetContainerNoNull()
                Else
                    Me.DataRow.ContainerNo = Value
                End If
            End Set
        End Property

        Public Property ETA() As System.DateTime
            Get
                If Me.DataRow.IsETANull Then
                    Return Nothing
                Else
                    Return Me.DataRow.ETA
                End If
            End Get
            Set(ByVal Value As System.DateTime)
                If Value = Nothing Then
                    Me.DataRow.SetETANull()
                Else
                    Me.DataRow.ETA = Value
                End If
            End Set
        End Property

        Public Property Week() As System.Int32
            Get
                If Me.DataRow.IsWeekNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.Week
                End If
            End Get
            Set(ByVal Value As System.Int32)
                If Value = Nothing Then
                    Me.DataRow.SetWeekNull()
                Else
                    Me.DataRow.Week = Value
                End If
            End Set
        End Property

        Public Property ArrivalPort() As System.String
            Get
                If Me.DataRow.IsArrivalPortNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.ArrivalPort
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetArrivalPortNull()
                Else
                    Me.DataRow.ArrivalPort = Value
                End If
            End Set
        End Property

        Public Property PI() As System.String
            Get
                If Me.DataRow.IsPINull Then
                    Return Nothing
                Else
                    Return Me.DataRow.PI
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetPINull()
                Else
                    Me.DataRow.PI = Value
                End If
            End Set
        End Property

        Public Property Payment() As System.String
            Get
                If Me.DataRow.IsPaymentNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.Payment
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetPaymentNull()
                Else
                    Me.DataRow.Payment = Value
                End If
            End Set
        End Property

        Public Property DocReceived() As System.Boolean
            Get
                If Me.DataRow.IsDocReceivedNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.DocReceived
                End If
            End Get
            Set(ByVal Value As System.Boolean)
                If Value = Nothing Then
                    Me.DataRow.SetDocReceivedNull()
                Else
                    Me.DataRow.DocReceived = Value
                End If
            End Set
        End Property

        Public Property CompletedDate() As System.DateTime
            Get
                If Me.DataRow.IsCompletedDateNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.CompletedDate
                End If
            End Get
            Set(ByVal Value As System.DateTime)
                If Value = Nothing Then
                    Me.DataRow.SetCompletedDateNull()
                Else
                    Me.DataRow.CompletedDate = Value
                End If
            End Set
        End Property

        Public Property BulkType() As System.String
            Get
                If Me.DataRow.IsBulkTypeNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.BulkType
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetBulkTypeNull()
                Else
                    Me.DataRow.BulkType = Value
                End If
            End Set
        End Property

        Public Property ModifiedDate() As System.DateTime
            Get
                If Me.DataRow.IsModifiedDateNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.ModifiedDate
                End If
            End Get
            Set(ByVal Value As System.DateTime)
                If Value = Nothing Then
                    Me.DataRow.SetModifiedDateNull()
                Else
                    Me.DataRow.ModifiedDate = Value
                End If
            End Set
        End Property

        Public Property CurrentDate() As System.DateTime
            Get
                If Me.DataRow.IsCurrentDateNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.CurrentDate
                End If
            End Get
            Set(ByVal Value As System.DateTime)
                If Value = Nothing Then
                    Me.DataRow.SetCurrentDateNull()
                Else
                    Me.DataRow.CurrentDate = Value
                End If
            End Set
        End Property

        Public ReadOnly Property IsSalesOrderNull() As Boolean
            Get
                Return Me.DataRow.IsSalesOrderNull
            End Get
        End Property

        Public Property SalesOrder() As System.Int32
            Get
                If Me.DataRow.IsSalesOrderNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.SalesOrder
                End If
            End Get
            Set(ByVal Value As System.Int32)
                If Value = Nothing Then
                    Me.DataRow.SetSalesOrderNull()
                Else
                    Me.DataRow.SalesOrder = Value
                End If
            End Set
        End Property

        Public Property CustPONo() As System.String
            Get
                If Me.DataRow.IsCustPONoNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.CustPONo
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetCustPONoNull()
                Else
                    Me.DataRow.CustPONo = Value
                End If
            End Set
        End Property

        Public ReadOnly Property IsInvValueNull() As Boolean
            Get
                Return Me.DataRow.IsInvValueNull
            End Get
        End Property

        Public Property InvValue() As System.Decimal
            Get
                If Me.DataRow.IsInvValueNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.InvValue
                End If
            End Get
            Set(ByVal Value As System.Decimal)
                If Value = Nothing Then
                    Me.DataRow.SetInvValueNull()
                Else
                    Me.DataRow.InvValue = Value
                End If
            End Set
        End Property
#End Region

    End Class

End Class

